import os, sys
from _util import run_cmd, get_site_packages_path

os.putenv('PYTHON', sys.executable)

python_bin_path = os.path.dirname(sys.executable)
os.putenv('PYTHON_BIN_PATH', python_bin_path)

pylint_location = os.path.join(python_bin_path, "pylint")
os.putenv('PYLINT', pylint_location)

sp = get_site_packages_path()
os.putenv('SITE_PACKAGES_PATH', sp)

basedir = os.path.abspath(os.path.dirname(__file__))
if len(sys.argv) == 1:
        name = 'Cheesecake'
else:
        name = sys.argv[1]
script = os.path.join(basedir, name + '.sh')
if not os.path.exists(script):
    print 'Unknown project: %s' % (name,)
    sys.exit(1)
cmd = script
print "Running", cmd
rc, output = run_cmd(cmd)
print output
print "Exit code:", rc
sys.exit(rc)
